<?php

    require ( 'init.inc.php' );
    require ( 'checkadmin.inc.php');
    require ( __COMM_PATH . 'pagecontrol.inc.php' );
    require ( __COMM_PATH . 'checkform.func.php' );
    require ( __CLASS_PATH . 'page_edit.class.php' );

    // -------------------------------------------------------
    // 接收传递过来的变量
    // -------------------------------------------------------
    $action = $_REQUEST["action"];
    $id     = addslashes($_REQUEST["id"]);
    $classid = intval($_GET["classid"]);
    if (!is_numeric($classid)) feedback($clang["pls_enter_news_class"]);

    // -------------------------------------------------------
    // 页面基本设置
    // -------------------------------------------------------
    $page_title   = $ptitle["news_add"];                        // 页面标题
    $page_type    = "add";                                      // 页面类型
    $display_page = "aomen_info_edit.htm";                            // Smarty 模板页面
    $table_name   = "{$tablepre}aomen";                          // 表名
    $condition    = "WHERE `classid`='{$classid}'";             // 查询条件
    $back_page    = "aomen_info_list.php?sortby={$_GET['sortby']}&oexp={$_GET['oexp']}&page={$_GET['page']}&classid={$classid}&keyword={$_GET['keyword']}";

    // -------------------------------------------------------
    // 保存编辑数据
    // -------------------------------------------------------
    if ($action=="submit") {
        $title = dhtmlspecialchars(check_empty($_POST["title"],$clang[title]));
        $images = dhtmlspecialchars($_POST["images"]);
		$hot=intval($_POST['hot']);
		$type=intval($_POST['type']);
		$address=intval($_POST['address']);
        $content = $_POST['content'];
        $addtime = date ("Y-m-d", strtotime($_POST["addtime"]));
        $adduser = dhtmlspecialchars($_POST["adduser"]);
        $fields_arr = array(
            "classid" => $classid,
            "title" => $title,
            "img" => $images,
            "type" =>$type,
            "address" => $address,
            "content" => $content,
			"hot" => $hot,
            "adduser" => $adduser,
            "addtime" => $addtime
        );
		file_log($_SESSION['AdminUser'],"添加澳门介绍信息");
    }

    // -------------------------------------------------------
    // 解析基本信息
    // -------------------------------------------------------
    $tpl->assign("classid", $classid);
    $tpl->assign("hot", 1);
    $tpl->assign('addtime', date("Y-m-d"));
    $tpl->assign('adduser', $_SESSION["AdminUser"]);

    // -------------------------------------------------------
    // 执行页面处理
    // -------------------------------------------------------
	$tpl->assign("classid", $classid);
    show_page_head($page_type, $page_title);
    $pedit = new PageEdit($page_title, $back_page, $page_type); // 实例化一个编辑页面
    $pedit->SetParam($table_name, $condition);                  // 设置数据库基本参数，查询条件
    $pedit->InsertData($fields_arr);                            // 更新数据
    $pedit->TplParse($display_page);                            // 自动解析相关数据到 Smarty 模板
    show_page_foot();
    $db->close();
?>